﻿using System.Collections.Generic;
using System.Globalization;
using System.Threading;

namespace Composr.Core
{
    /// <summary>
    /// culture wrapper - this was written with only bilingual english and french in mind
    /// but can be extended to support any culture by adding more values or reading from db (locales table)
    /// </summary>
    public class UICultureSettings:CultureInfo
    {
        public UICultureSettings(Locale locale) : base(locale.ToString().ToLower()) { Locale = locale; }

        /// <summary>
        /// supported ids 
        /// </summary>
        public Locale Locale { get; private set; }
            
        /// <summary>
        /// utility function to get the current executing culture
        /// </summary>
        /// <returns></returns>
        public static UICultureSettings ExecutingCultureSettings
        {
            get
            {
                UICultureSettings culture = Thread.CurrentThread.CurrentUICulture as UICultureSettings;
                if (culture == null) culture = new UICultureSettings(Locale.EN);
                return culture;
            }
        }
    }
}